package com.dh.testsjsx;

/**
 *协变返回类型
 */
class Grain{
    @Override
    public String toString() {
        return "Grain{}";
    }
}

class Wheat extends Grain{
    @Override
    public String toString() {
        return "Wheat{}";
    }
}
class  Mill{
    Grain process(){
        return new Grain();
    }
}
class WheatMill extends Mill{
    Wheat process(){
        return new Wheat();
    }
}

public class Covar {
    public static void  main(String args[]){
        Mill m=new Mill();
        Grain g=m.process();
        System.out.println(g);
        m=new WheatMill();
        g=m.process();
        System.out.println(g);
    }
}
